import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        char[] ch = in.next().toCharArray();
        int[][] dp = new int[a][3];
        dp[0][0] = ch[0] == 's' ? 1:0;
        for(int i = 1;i < a;i++){
            dp[i][0] = dp[i - 1][0];
            dp[i][1] = dp[i - 1][1];
            dp[i][2] = dp[i - 1][2];
            if(ch[i] == 's')dp[i][0] +=  1;
            if(ch[i] == 'h')dp[i][1] += dp[i][0];
            if(ch[i] == 'y')dp[i][2] += dp[i][1];
        }
        System.out.println(dp[a - 1][2]);
    }
}
//8
//sshhyyau